<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>过滤HTML标签</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
    </style>
</head>
<body>
	<div class="container">
		<h1>过滤HTML标签</h1>
		<textarea id="txt1" rows="10" cols="40">
			我在北京的<strong>百度</strong>总部上班，然后我在上班期间打开淘宝进行购物，被公司<span>发现</span>开除了
		</textarea><br>
		<input id="btn1" type="button" value="过滤HTML标签" /><br>
		<textarea id="txt2" rows="10" cols="40">	
		</textarea>
	</div>
	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script type="text/javascript">
	
		var oTxt1=document.getElementById('txt1');
		var oTxt2=document.getElementById('txt2');
		var oBtn=document.getElementById('btn1');
		
		function fun1 () {
			console.log('采用的第一种方法')
			var re=/<(.*?)>(.*?)<\/\1>/g;
			console.log(oTxt1.value)
			console.log(oTxt1.innerHTML)
			oTxt2.innerHTML = oTxt1.value.replace(re, '$2')
			
		}

		function fun2 () {
			console.log('采用的第二种方法')
			var re=/<[^<>]+>/g
			console.log(oTxt1.value)
			console.log(oTxt1.innerHTML)
			oTxt2.innerHTML = oTxt1.value.replace(re, '')
		}

		oBtn.onclick = function () {
			fun2()
		}
	</script>
</body>
</html>